(* Find the last element of a list. *)

let rec last = function
  | [] -> None
  | [x] -> Some x
  | _::t -> last t
;;

assert (last  [ `a ; `b ; `c ; `d ]= Some `d) ;;
assert (last [] = None) ;; 

let output v = 
  match v with
  None -> print_endline "None"
  |Some `a -> print_endline "Some a"
  |Some `b -> print_endline "Some b"
;;

output(last[`a; `b]);;

type t = Int of int|String of string|None;;

let result v =
  match v with
  None -> print_endline "None"
  |Int v -> print_int v
  |String v -> print_string v
;;

result (Int 4);;
